<template>
    <div>
    <Tolaunch ref="fileUploadDialog"  input = "input" textarea ="textarea"></Tolaunch>
    
     <p>请输入文章标题:<span class="required" style="color:red">*</span></p>
     <el-input
       placeholder="请输入内容"
       v-model="input"
       clearable
       @click="check">
     </el-input>
      <el-alert
    title="该项必填"
    type="info"
    v-show="al === true"
    >
  </el-alert>


     <br>
     <br>
     <p>请选择文章类别</p>
     <el-cascader
    placeholder="请选择预发布文献标签"
    :options="options"
    :props="{ multiple: true }"
    filterable></el-cascader>
   


     <br>
     <br>
     <p>文章简介</p>
     <el-input
    type="textarea"
    :rows="2"
    placeholder="请输入内容"
    v-model="textarea">
    </el-input>
    <br>

    <br>

    <br>

    <br>
    <author></author>
    <div v-for="(d,index) in counter" :key="index">
	      <SndAu :index="index" :form="d"></SndAu>
    </div>
   <el-button type="primary" @click="add">添加其他作者</el-button>
<br>
<br>
<br>
     <el-button
       type="primary"
       plain
       icon="el-icon-plus"
       @click="handleAdd"
       :disabled="!notEdit"
       :auththor="this.input"
     >上传<i class="el-icon-upload el-icon--right"></i></el-button>

  
   
    </div>
</template>

<script>
import Tolaunch from './tolaunchfile_p.vue'
import author from '../IDCARD.vue'
import SndAu from './SndAuyhor.vue'
export default {

  data(){
    return{
      authorname:'',
      al:false,
      counter:[],
       form:{
        noticeId:1
      },
      notEdit:true,
      input:'',
      textarea:'',
      options: [{
          value: 'nonglinmuyu_weisheng_kexueyanjiu',
          label: '农林牧渔、卫生、科学研究',
          children: [{
            value: 'nonglinyumu',
            label: '农林渔牧',
            children: [{
              value: 'nongye',
              label: '农业'
            }, {
              value: 'ziranziyuan',
              label: '自然资源'
            }, {
              value: 'linye',
              label: '林业'
            }]
          }, {
              value: 'weisheng',
              label: '卫生',
              children: [{
              value: 'shipin',
              label: '食品'
            }, {
              value: 'yiliao',
              label: '医疗'
            }, {
              value: 'yaoye',
              label: '药业'
            }, {
              value: 'gonggongweisheng',
              label: '公共卫生'
            }, {
              value: 'haiguanjianyan',
              label: '海关检验'
            }]
          }, {
          value: 'kexueyanjiu',
          label: '科学研究',
          children: [{
            value: 'ziranziyuan',
            label: '自然资源',
            children: [{
              value: 'shuili',
              label: '水利'
            }, {
              value: 'qixiang',
              label: '气象'
            }, {
              value: 'haiyang',
              label: '海洋'
            }, {
              value: 'shengwu',
              label: '生物'
            }, {
              value: 'kuangchan',
              label: '矿产'
            }]
          }]
        }]
      } , {
      value: 'jianshezhizao',
      label: '建设制造',
      children: [{
        value:'jianzhu',
        label: '建筑'
      }, {
        value:'jianzhucailiao',
        label:'建筑材料'
      }, {
        value:'chengxiangguihua',
        label:'城乡规划'
      }, {
        value: 'jiaotongyunshu',
        label: '交通运输'
      },{
        value: 'jixiezhizao',
        label: '机械电子制造',
        children: [{
          value:'dianzidianqi',
          label:'电子电气'
        }, {
          value:'hangkonghangtian',
          label: '航空航天'
        }, {
          value:'jiadian',
          label: '家电'
        }, {
          value:'qiche',
          label:'汽车'
        }]
      }]
    },{
      value:'jinrong_falv_zhengce',
      label:'金融_法律_政策',
      children:[{
        value:'falv',
        label:'法律'
      }, {
        value:'dangzheng',
        label:'党政'
      }, {
        value:'guofang',
        label:'国防'
      }, {
        value: 'kuaiji',
        label: '会计'
      }, {
        value: 'zhili',
        label: '治理'
      }, {
        value: 'jinrong',
        label: '金融'
      }]
    }, {
      value:'jiaoyukeyan',
      label:'教育科研',
      children:[{
        value: 'jiaoyu',
        label: '教育',
        children:[{
          value:'tiyu',
          label:'体育'
        }, {
          value:'xuekejiaoliu',
          label:'学科交流',
          children:[{
            value:'shuxue',
            label:'数学'
          }, {
            value:'guoxue',
            label:'国学'
          }, {
            value: 'shengmingkexue',
            label: '生命科学'
          }, {
            value:'wulihuaxue',
            label:'物理化学'
          }]

        }, {
          value:'wenhua',
          label:'文化',
          children:[{
            value:'chuantongwenhua',
            label:'传统文化'
          }, {
            value:'feiyi',
            label:'非遗'
          }, {
            value: 'wenyi',
            label: '文艺'
          }]
        }]
      }]
    }],
  }},
  
components:{
       Tolaunch,
       author,
       SndAu
   } ,
methods:{
  changeauthorname(name){
      this.authorname=name
  },
  check(){
      if (this.input === " ") {
            alert("必须填写！")
           this.al=true;
        }

  },
  add(){
        this.counter.push({
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
      })
  },
  delete(i){
      this.counter.splice(i,1)
  },
      handleAdd() {
   this.$refs.fileUploadDialog.show()
 },
 getAttachList() {
   this.loading = true
   this.attachQuery.billId = this.form.noticeId
   this.attachQuery.billType = 10
   listAttachment(this.attachQuery).then(response => {
     this.attachList = response.rows
     this.attachList.forEach(el => {
       // 转为kb，取小数点后2位
       el.fileSize = parseFloat(el.fileSize / 1024).toFixed(2)
     })
     this.attachTotal = response.total
     this.loading = false
   }).catch(() => {})
 },

   }
  
}
</script>


<style>
.text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 480px;
  }
</style>